import 'package:cat_eye/base/base_refresh_view_model.dart';
import 'package:cat_eye/bean/home_body_bean.dart';
import 'package:cat_eye/config/string_config.dart';
import 'package:cat_eye/config/url_config.dart';
import 'package:flutter/material.dart';

/*
* @Package: view_model.find_view_model
* @ClassName: find_recommend_view_model
* @Author: szj
* @CreateDate: 8/4/21 8:15 PM
* TODO 发现-推荐ViewModel
*/
class FindRecommendViewModel extends BaseRefreshViewModel {
  List<ItemList> itemList = [];

  String loadMoreUrl = "";

  @override
  String get httpLoadMoreUrl => loadMoreUrl;

  @override
  String get httpUrl => UrlConfig.communityUrl;

  @override
  void refresh() {
    if (itemList.length > 0) itemList.clear();
    super.refresh();
  }

  @override
  void successJsonData(json) {
    var issueList = IssueList.fromJson(json);

    issueList.itemList.forEach((element) {
      //不添加这个类型的
      if(element.type != StringConfig.HORIZONTAL_SCROLL_CARD){
        itemList.add(element);
      }
    });

    loadMoreUrl = issueList.nextPageUrl;
  }
}
